<div class="judul"><?php echo anchor("/member/", $title);?></div>
<script type="text/javascript">
    $(document).ready(function(){
        $('input[type=submit]').click(function(){
            if($('#nama').val() == ""){
                alert('Nama member harus diisi');
                $('#nama').focus();
                return false;
            }
            if($('#tglLahir').val() == ""){
                alert('Tanggal lahir harus diisi');
                $('#tglLahir').focus();
                return false;
            }
            if($('#alamat').val() == ""){
                alert('Alamat harus diisi');
                $('#alamat').focus();
                return false;
            }
            if($('#noTelp').val() == ""){
                alert('No. Telepon harus diisi');
                $('#noTelp').focus();
                return false;
            }
            if($('#pekerjaan').val() == ""){
                alert('Pilih salah satu pekerjaan');
                $('#pekerjaan').focus();
                return false;
            }
            if($('.jenis_keanggotaan_br').length == 0){
               if(($('.baris').length == 1) && $('#jenisMember').val() == ""){
                  alert('Pilih jenis keanggotaan minimal 1');
                  return false;
               }                 
            }
        })
    })
</script>
<?php
  $flashdata = $this->session->flashdata('message');
  $messages = isset ($flashdata)?pesan($flashdata):"";
  echo "$messages";
  $form = isset ($formView)?$formView:"";
  if($form != ""){
     $this->load->view("$form"); 
  }
?>
<div class="data-list">
    <div class="floleft" style="margin: 8px 0">
    <?php
      foreach ($user['keanggotaan'] as $keanggotaans);
      if(in_array('Head', $keanggotaans) || in_array('Super Admin', $keanggotaans)){
            echo addButton('member/add_member_form', 'tambah');
      }
    ?>
    </div>
    <div class="floright">
        <?php
          echo form_open('member/search');
        ?>
        <?
          echo form_input('nama','','class=search-input');
          echo form_hidden('url',$searchLink);
          echo form_submit('cari', '', 'id=search class=search-button');
          echo form_close();
        ?>
    </div>
    <table class="tabel" style="width: 100%">
        <tr>
            <th>No</th>
            <th><a class="sorting" href="<?php echo "$sortNama";?>">Nama</a></th>
            <th>Tgl. Lahir</th>
            <th>Jenis Kelamin</th>
            <th>Alamat</th>
            <th>No. Telepon</th>
            <th>Pekerjaan</th>
            <th>Jenis Keanggotaan</th>
            <th>Aksi</th>
        </tr>
        <?php
            $offsets = isset ($offset)?$offset:0;
            $no = 1 + $offsets;
            foreach ($listMember as $key => $row){
        ?>
          <tr class="<?php echo ($no%2)?"even":"odd"?>">
              <td align="center" style="width: 3%"><?php echo $no++;?></td>
              <td class="no-wrap"><?php echo anchor("/member/detail_member/".$row['member']['id'],$row['member']['member']);?></td>
              <td style="width: 7%;text-align: center"><?php echo datefmysql($row['member']['tgl_lahir']);?></td>
              <td style="width: 7%;text-align: center"><?php echo $row['member']['jenis_kelamin'];?></td>
              <td style="width: 20%"><?php echo $row['member']['alamat'];?></td>
              <td style="width: 7%"><?php echo $row['member']['no_telp'];?></td>
              <td><?php echo $row['member']['pekerjaan'];?></td>
              <td><?php
                 foreach ($row['jenis_keanggotaan'] as $rows){
                     echo "$rows[jenis_member] ";
                 }
              ?></td>
              <td class="aksi">
                  <?php
                    if(in_array('Head', $keanggotaans) || in_array('Super Admin', $keanggotaans)){
                        echo anchor('member/edit_member_form/'.$row['member']['id'], 'edit', 'class=edit title="edit"');
                        echo anchor('member/delete_member/'.$row['member']['id'],'hapus','class=delete title="edit" onClick="return confirm(\'Apakah anda benar-benar akah menghapus data ini\')"');
                    }else{
                        echo '-';
                    }
                  ?>
              </td>
          </tr>
        <?
            }
        ?>
    </table>
</div>
<?php
  echo "$pagination";
?>
